/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * EntradasCinemark.java
 *
 * Created on 21-feb-2011, 12:11:06
 */
package cinemark;

import java.awt.Graphics;
import java.util.Date;
import javax.swing.DefaultListSelectionModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import java.text.SimpleDateFormat;

/**
 *
 * @author CMILLER
 */
public class EntradasCinemark extends javax.swing.JFrame {

    private Control control;
    private DefaultTableModel mdlDetBoletos;
    private int nt = 0;

    /** Creates new form EntradasCinemark */
    public EntradasCinemark() {
        initComponents();
        control = new Control();
        mdlDetBoletos = (DefaultTableModel) tblBoletos.getModel();
        tblBoletos.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION);
        // Mostrar la lista de alumnos
        mostrarDetBoletos();
    }

    private void mostrarDetBoletos() {
        // Establecer la cantidad de filas de la tabla alumnos
        mdlDetBoletos.setRowCount(control.getDetBoletos().size());
        // Volcar el contenido de cada entidad Alumno en la tabla
        for (int i = 0; i < control.getDetBoletos().size(); i++) {
            DetBoleto detBoleto = control.getDetBoletos().get(i);
            //setValueArt(valor, fila,  columna.
            mdlDetBoletos.setValueAt(detBoleto.getnTicket(), i, 0);
            mdlDetBoletos.setValueAt(detBoleto.getHorario(), i, 1);
            mdlDetBoletos.setValueAt(detBoleto.getSala(), i, 2);
            mdlDetBoletos.setValueAt(detBoleto.getGenero(), i, 3);
            mdlDetBoletos.setValueAt(detBoleto.getPelicula(), i, 4);
            mdlDetBoletos.setValueAt(detBoleto.getCaja().getCantidad(), i, 5);
            mdlDetBoletos.setValueAt(detBoleto.getCaja().calcularPrecioTotal(), i, 6);
        }

    }

    private void mostrarCierreDiario() {
        // double notaFinalMayor = profesor.obtenerNotaFinalMayor();
        double cantidadTotal = control.CalcularCantidadTotal();
        double importeTotal = control.CalcularImporteTotal();
        txtCantidadTotal.setText(String.valueOf(cantidadTotal));
        txtImporteTotal.setText(String.valueOf(importeTotal));
        //txtNotaFinalMenor.setText(String.valueOf(notaFinalMenor));
        // txtPromedioSalon.setText(String.valueOf(promedioSalon));
    }

    private void entradasLibres(){

     double libres = 120-Double.parseDouble(txtCantidadTotal.getText());
              txtLibres.setText(String.valueOf(libres));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblBoletos = new javax.swing.JTable();
        btnGrabar = new javax.swing.JButton();
        btnAnular = new javax.swing.JButton();
        btnCaja = new javax.swing.JButton();
        btnsalir = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel19 = new javax.swing.JLabel();
        txtLibres = new javax.swing.JTextField();
        pnlFondo = new javax.swing.JPanel();
        cbxSala = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        cbxGenero = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        txtTicket = new javax.swing.JTextField();
        txtFecha = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        cbxPelicula = new javax.swing.JComboBox();
        jLabel6 = new javax.swing.JLabel();
        cbxHorario = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        txtImporteTotal = new javax.swing.JTextField();
        txtCantidadTotal = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtsinopsis = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        tblBoletos.setBackground(new java.awt.Color(204, 255, 204));
        tblBoletos.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "N° Ticket", "Horario", "Sala", "Genero", "Pelicula", "Catidad", "PrecioT"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Object.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Object.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        tblBoletos.setGridColor(new java.awt.Color(102, 204, 255));
        jScrollPane1.setViewportView(tblBoletos);

        btnGrabar.setText("Grabar");
        btnGrabar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGrabarActionPerformed(evt);
            }
        });

        btnAnular.setText("Anular");
        btnAnular.setAutoscrolls(true);
        btnAnular.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAnularActionPerformed(evt);
            }
        });

        btnCaja.setLabel("Caja");
        btnCaja.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCajaActionPerformed(evt);
            }
        });

        btnsalir.setText("Salir");
        btnsalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnsalirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 523, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnsalir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnCaja, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnAnular, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(btnGrabar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(36, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(btnGrabar)
                        .addGap(11, 11, 11)
                        .addComponent(btnAnular)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnCaja)
                        .addGap(101, 101, 101)
                        .addComponent(btnsalir, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel19.setText("Libres");

        txtLibres.setEditable(false);
        txtLibres.setText("00.00");
        txtLibres.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtLibresActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(435, Short.MAX_VALUE)
                .addComponent(jLabel19)
                .addGap(18, 18, 18)
                .addComponent(txtLibres, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(136, 136, 136))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtLibres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pnlFondo.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        cbxSala.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sala 1", "Sala 2", "Sala 3", "Sala 4" }));
        cbxSala.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxSalaActionPerformed(evt);
            }
        });

        jLabel3.setText("Sala");

        jLabel4.setText("Genero");

        cbxGenero.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Aventura", "Comedia Romantica", "Drama", "Terror" }));

        jLabel1.setText("N° Ticket");

        txtTicket.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                txtTicketKeyTyped(evt);
            }
        });

        txtFecha.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtFechaActionPerformed(evt);
            }
        });

        jLabel2.setText("Fecha");

        jLabel5.setText("Pelicula");

        cbxPelicula.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "El AvisponVerde", "Como si fuera la primera vez", "El cisne Negro", "El Aro" }));
        cbxPelicula.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxPeliculaActionPerformed(evt);
            }
        });

        jLabel6.setText("Horario");

        cbxHorario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "5:00-7:00", "7:00-9:00", "9:00-11:00", " " }));

        jLabel7.setIcon(new javax.swing.ImageIcon("C:\\Documents and Settings\\U201100227\\Desktop\\Cinemark_1.0\\Cinemark\\LogoCINEMARK.jpg")); // NOI18N
        jLabel7.setText("jLabel7");

        javax.swing.GroupLayout pnlFondoLayout = new javax.swing.GroupLayout(pnlFondo);
        pnlFondo.setLayout(pnlFondoLayout);
        pnlFondoLayout.setHorizontalGroup(
            pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFondoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlFondoLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cbxSala, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel4))
                    .addGroup(pnlFondoLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtTicket, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(pnlFondoLayout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(cbxGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbxPelicula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(22, 22, 22))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlFondoLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(89, 89, 89)))
                .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtFecha)
                    .addComponent(cbxHorario, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(44, Short.MAX_VALUE))
        );
        pnlFondoLayout.setVerticalGroup(
            pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlFondoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(pnlFondoLayout.createSequentialGroup()
                            .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel1)
                                .addComponent(txtTicket, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                        .addGroup(pnlFondoLayout.createSequentialGroup()
                            .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel2)
                                .addComponent(txtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(18, 18, 18)))
                    .addComponent(jLabel7))
                .addGap(39, 39, 39)
                .addGroup(pnlFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(cbxSala, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(cbxHorario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(cbxGenero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(cbxPelicula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(41, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel9.setText("Sinopsis");

        jLabel15.setText("Cantidad Total :");

        jLabel16.setText("Importe total:");

        txtImporteTotal.setEditable(false);
        txtImporteTotal.setText("00.00");
        txtImporteTotal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtImporteTotalActionPerformed(evt);
            }
        });

        txtCantidadTotal.setEditable(false);
        txtCantidadTotal.setText("00.00");
        txtCantidadTotal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtCantidadTotalActionPerformed(evt);
            }
        });

        txtsinopsis.setColumns(20);
        txtsinopsis.setEditable(false);
        txtsinopsis.setLineWrap(true);
        txtsinopsis.setRows(5);
        jScrollPane2.setViewportView(txtsinopsis);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(309, 309, 309))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel15)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtImporteTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCantidadTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(179, 179, 179))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
                .addGap(4, 4, 4)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtCantidadTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(txtImporteTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(74, 74, 74))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnlFondo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pnlFondo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(12, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnGrabarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGrabarActionPerformed
        // TODO add your handling code here:

        nt = nt + 1;
       txtTicket.setText(Integer.toString(nt));

        String nTicket = txtTicket.getText();
        String horario = cbxHorario.getSelectedItem().toString();
        String sala = cbxSala.getSelectedItem().toString();
        String genero = cbxGenero.getSelectedItem().toString();
        String pelicula = cbxPelicula.getSelectedItem().toString();
        // String cantidad = txtCantidad.getText();
        //     double cantidad = Double.parseDouble(txtCantidad.getText());

        //    String modalidad = cbxModalidad.getSelectedItem().toString();
        if (!nTicket.equals("") && !pelicula.equals("")) {
            if (control.buscarDetBoleto(nTicket) == null) {
                control.registrarDetBoleto(nTicket, horario, sala, genero, pelicula);
                mostrarDetBoletos();
                mostrarCierreDiario();
                entradasLibres();
                //                     mostrarAnular();
                txtTicket.setText("");
                //txtCantidad.setText("");
                //cbxPelicula.setSelectedItem("");
                txtTicket.requestFocusInWindow();
            } else {
                JOptionPane.showMessageDialog(rootPane, "Código ya registrado.");
            }
      }
         //   else {
//            JOptionPane.showMessageDialog(rootPane, "Falta ingresar datos");
//        }
}//GEN-LAST:event_btnGrabarActionPerformed

    private void btnAnularActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAnularActionPerformed
        // TODO add your handling code here:
        int fila = this.tblBoletos.getSelectedRow();
        if (fila != -1) {
            // Obtener el codigo de la fila seleccionada
            String nTicket = this.mdlDetBoletos.getValueAt(fila, 0).toString();
            // Eliminar al alumno con el codigo obtenido
            this.control.eliminarDetBoleto(nTicket);
            mostrarDetBoletos();
            mostrarCierreDiario();
            entradasLibres();

        }
}//GEN-LAST:event_btnAnularActionPerformed

    private void btnCajaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCajaActionPerformed

        int fila = this.tblBoletos.getSelectedRow();
        if (fila != -1) {
            String nTicket = this.mdlDetBoletos.getValueAt(fila, 0).toString();

            CajaDiaria cajad = new CajaDiaria(this,
                    true,
                    control,
                    nTicket);
            cajad.setLocationRelativeTo(this);

            cajad.setVisible(true);
            cajad.dispose();
            mostrarDetBoletos();
            mostrarCierreDiario();
            entradasLibres();

        }
}//GEN-LAST:event_btnCajaActionPerformed

    private void cbxSalaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxSalaActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_cbxSalaActionPerformed

    private void txtTicketKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTicketKeyTyped
        char caracter = evt.getKeyChar();
        if (((caracter < '0') ||
                (caracter > '9')) &&
                (caracter != evt.VK_BACK_SPACE)) {
            evt.consume();
        }
        // TODO add your handling code here:
}//GEN-LAST:event_txtTicketKeyTyped

    private void txtFechaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtFechaActionPerformed

        java.util.Date fecha = new Date();
        fecha.getDay();

        //System.out.println (fecha.getDay());
        //System.out.println (fecha.getMonth());// TODO add your handling code here:
}//GEN-LAST:event_txtFechaActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        // TODO add your handling code here:
       // nt = nt + 1;
        //txtTicket.setText(Integer.toString(nt));

        if (cbxPelicula.getSelectedIndex() == 0) {
            txtsinopsis.setText("Britt Reid es el dueño de un famoso periódico que por las noches se convierte en el Avispón Verde, un justiciero enmascarado al cual todos ven como un ladrón sin escrúpulos. Su identidad secreta le mantiene protegida del mundo, aunque Kato, su fiel y habilidoso chofer, conoce el secreto, siendo además el segundo héroe de la ciudad. ");
        }
        txtTicket.setEditable(false);
        txtFecha.setEditable(false);
        SimpleDateFormat fecha = new SimpleDateFormat("dd/MM/yyyy");
        txtFecha.setText(fecha.format(new Date()));
    }//GEN-LAST:event_formWindowActivated

    private void txtImporteTotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtImporteTotalActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtImporteTotalActionPerformed

    private void txtCantidadTotalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCantidadTotalActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtCantidadTotalActionPerformed

    private void cbxPeliculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxPeliculaActionPerformed

        // TODO add your handling code here:
        int sinopsis = cbxPelicula.getSelectedIndex();

        switch (sinopsis) {
            case 0:
                txtsinopsis.setText("Britt Reid es el dueño de un famoso periódico que por las noches se convierte en el Avispón Verde, un justiciero enmascarado al cual todos ven como un ladrón sin escrúpulos. Su identidad secreta le mantiene protegida del mundo, aunque Kato, su fiel y habilidoso chofer, conoce el secreto, siendo además el segundo héroe de la ciudad. ");
                break;
            case 1:
                txtsinopsis.setText("El biólogo marino Henry encuentra a la mujer perfecta: Lucy Whitmore y se enamora de ella. Pero cuando se ven al día siguiente, ella no tiene la más mínima idea quién es él. Lucy sufre un extraño desorden cerebral que borra lo ocurrido durante el día de su memoria cada noche. Ahora con la ayuda de su amigo Ula debe encontrar la forma de encontrarla y hacer que se enamore de él cada santo día.");
                break;
            case 2:
                txtsinopsis.setText("El filme sigue la historia de Nina (Natalie Portman), una bailarina en una compañía de ballet de la ciudad de Nueva York cuya vida, como todos los de su profesión, se consume totalmente con la danza. Ella vive con su madre, también bailarina retirada, Erica (Barbara Hershey), que apoya las pretensiones de celo profesional de su hija.");
                break;
            case 3:
                txtsinopsis.setText("Una misteriosa cinta de video parece ser la causa de la muerte de cuatro jóvenes en extrañas circunstancias. La tía de uno de ellos, Rachel (Naomi Watts), consigue hacerse con la cinta. Tras visionarla recibe una terrorífica llamada telefónica que le advierte que en el plazo de una semana morirá.");
                break;
        }
    }//GEN-LAST:event_cbxPeliculaActionPerformed

    private void txtLibresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtLibresActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_txtLibresActionPerformed

    private void btnsalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnsalirActionPerformed
        // TODO add your handling code here:
        System.exit(0);
        
    }//GEN-LAST:event_btnsalirActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new EntradasCinemark().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAnular;
    private javax.swing.JButton btnCaja;
    private javax.swing.JButton btnGrabar;
    private javax.swing.JButton btnsalir;
    private javax.swing.JComboBox cbxGenero;
    private javax.swing.JComboBox cbxHorario;
    private javax.swing.JComboBox cbxPelicula;
    private javax.swing.JComboBox cbxSala;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JPanel pnlFondo;
    private javax.swing.JTable tblBoletos;
    private javax.swing.JTextField txtCantidadTotal;
    private javax.swing.JTextField txtFecha;
    private javax.swing.JTextField txtImporteTotal;
    private javax.swing.JTextField txtLibres;
    private javax.swing.JTextField txtTicket;
    private javax.swing.JTextArea txtsinopsis;
    // End of variables declaration//GEN-END:variables
}
